Test Series - java script

Test Number 76/92

Q: What is the purpose of script loading?
A. Load Scripts programmatically
B. Load JavaScript files manually
C. Load JavaScript files programmatically
D. Load Scripts programmatically & manually
Solution: The script loading loads remote JavaScript files programmatically and allow us to trick the rendering engine. The async attribute is a boolean attribute. When present, it specifies that the script will be executed asynchronously as soon as it is available.
Q: What will happen if the browser encounters a script tag without an src attribute?
A. Throws an error
B. Throws an exception
C. Sends it to the compiler
D. Sends it to the interpreter
Solution: If the browser encounters a script tag without an src attribute, the rendering engine simply passes the code to the JavaScript Interpreter for execution. The src attribute specifies the location (URL) of the external resource.
Q: How to get a particular value using the tagged name?
A. getElementbyID()
B. getElementsbyName()
C. getElementsbyTagName()
D. getTagName()
Solution: The getElementsByTagName() method returns a collection of all elements in the document with the specified tag name, as a NodeList object. The method getElementsbyTagName() can be used to get a particular value using the tagged name associated with the document.
Q: What should be the type of script_url?
A. Object
B. String
C. Array
D. Any of the mentioned
Solution: The type of script_url can be anything that will be compared with the typeof keyword’s result. The src attribute specifies the location (URL) of the external resource.
Q: What is the purpose of using the async attribute in the script tag?
A. Load the script asynchronously
B. Load the script synchronously
C. Load the page asynchronously
D. Load the page synchronously
Solution: The async option is a native attribute that will tell the browser to load the script asynchronously. The async attribute is a boolean attribute. When present, it specifies that the script will be executed asynchronously as soon as it is available.
Q: Why do we need to use an onload event in the script tag after using the async attribute?
A. Invoke code during page loading
B. Invoke code during script loading
C. Invoke code during downloading
D. Invoke code during reloading
Solution: When using async you don’t know when the file will be downloaded, so you can attach an onload event handler to the script tag. This will allow you to invoke or instantiate any code that will need to be run when the file is downloaded:
Q: What is the purpose of the startTimeLogging() method?
A. Start the timer
B. Capture time logging
C. Capture timing data for referencing
D. All of the mentioned
Solution: The startTimeLogging() method captures the timing data for ad hoc, etc for referencing an uncached document.location. Once the startTimeLogging() method is called, run the code to test.
Q: What is the type of datatype the async attribute optionally accepts?
A. Integer
B. String
C. Boolean
D. Decimal
Solution: The async attribute is a boolean attribute. When present, it specifies that the script will be executed asynchronously as soon as it is available. The async attribute optionally accepts the boolean datatype of default value as true.
Q: What is the method used to create an element in the HTML DOM?
A. createDOMelement()
B. createElement()
C. createDOMElement()
D. create()
Solution: The createElement() can be used to create an element in the HTML DOM. After the element is created, use the element.appendChild() or element.insertBefore() method to insert it to the document.

You Have Score    /9